//
//  MeCell.swift
//  whale
//
//  Created by topnet on 2022/7/4.
//

import UIKit

class MeCell: WhaleListCell {

    override var mod: TableCellModelProtocol? {
        didSet {
            guard let item = mod as? ViewItemModel else { return }
            textLabel?.textColor = .title
            textLabel?.text = item.name
            detailTextLabel?.textColor = .content
            detailTextLabel?.text = item.content
        }
    }
    
    required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        contentView.addSubview(arrow)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        arrow.frame = CGRect(x: bounds.width - 30.adapter, y: bounds.height/2-10.adapter, width: 20.adapter, height: 20.adapter)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    private lazy var arrow: UILabel = {
        let lbl = UILabel()
        lbl.textColor = .white
        lbl.textAlignment = .right
        lbl.text = IconFont.arrow_right
        lbl.font = .iconfont(14)
        return lbl
    }()

}


class ViewItemModel: TableCellModelProtocol {
    
    var cellType: WhaleListCell.Type?
    
    var rowHeight: CGFloat?
    var name: String?
    var icon: String?
    var content: String?
    var vcType: UIViewController.Type?
    
    var vc: UIViewController?
    
    init(cellType: WhaleListCell.Type? = nil, rowHeight: CGFloat? = nil, name: String? = nil, icon: String? = nil, content: String? = nil, vcType: UIViewController.Type? = nil, vc: UIViewController? = nil) {
        self.cellType = cellType
        self.rowHeight = rowHeight
        self.name = name
        self.icon = icon
        self.content = content
        self.vcType = vcType
        self.vc = vc
    }
}
